
<html>
<body>
	<div id="main">

		<%@include file="header.jsp"%>
		<% 
		
		if(session.getAttribute("user")==null){
			response.sendRedirect("login.jsp");
				}
	else if (currentUser.getRole().equals(User.Role.TUTOR)){
		%>
		<div id=error>
			<p class="warning">
				As a tutor you can not track activities.<br>
			</p>
		</div>
		<%
			}
				
	 else{
		
		
		%>
		
		<fieldset>
			<legend> Your activities </legend>
			
		<table class='tablesorter' id='LinkTable' width='97%'>
			<thead>
				<tr>
					<th colspan="1">Course 
					<th colspan='1'>Duration</th>
					<th colspan='1'>Type</th>
					<th colspan='1'>Place</th>
					<th colspan='1'>Nr of pages</th>
					<th colspan='1'>Appreciation</th>
					
				</tr>
			</thead>
			<tbody>
			<%
			for (int i = 0; i < currentUser.getActivities().size(); i++) {
					Activity act = currentUser.getActivities().get(i);
					long timeLapseS =act.getDuration();
					long timeLapseM = timeLapseS / 60;
					long hours = timeLapseM / 60;
					long minutes = timeLapseM % 60;
					long seconds = timeLapseS % 60;
					
					String duration = hours +"h "+ minutes+"' "+seconds+"''";
					if(act.getDuration() == 0)
					{
		%>
					<tr>
					<td>
						<%=CourseRegistry.getInstance().getCourseById(act.getCourseId()).getCourseName()%>
					</td>
					<td colspan="5" style="text-align: center; color: #ff0000;">
						<%="This activity is under progress"%>
					</td>
					</tr>
		<% 
					} else {
		%>
		<tr>
		<td>
			<%=CourseRegistry.getInstance().getCourseById(act.getCourseId()).getCourseName()%>
		</td>
		<td>
			<%=duration%>
		</td>
		
		<td>
			<%=act.getType()%>	
		</td>
		<td>
			<%=act.getPlace()%>	
		</td>
		<td>
		<% 
		String nrOfPages = "/";
		if(act.getType().equals("Studying")){
			nrOfPages=""+act.getNrOfPages(); }%>
			<%=nrOfPages%>	
		</td>
		<td>
			<%=act.getAppreciation()%>	
		</td>
		</tr>
			<%
			}
			}
			%>
			</tbody>
		</table>
		
		</fieldset>
		
	</div>
	<%} %>
</body>
</html>